package com.atqinke.designpattern.behavioraltype.memo.whitebox;



import java.util.HashMap;
import java.util.Map;

/**
 * @BelongsProject: BasicConnection
 * @BelongsPackage: com.atqinke.designpattern.behavioraltype.memo.blackbox
 * @Author: NieHk
 * @CreateTime: 2022-08-29  18:00
 * @Description: 备忘录管理者类
 * @Version: 1.0
 */
public class RoleStateCaretaker {
    private Map<String, Memento> map = new HashMap<>();

    public Memento get(String name) {
        Memento roleStateMemento = map.get(name);
        if (roleStateMemento != null){
            return roleStateMemento;
        }else {
            throw new NullPointerException("暂无该快照节点");
        }
    }

    public void add(String name,Memento memento){
        System.out.println("保存节点： " + name);
        map.put(name,memento);
    }

}
